import request from '@/utils/request'

// 获取文章列表
export function getArticleList(params) {
  return request({
    url: '/admin/articles',
    method: 'get',
    params
  })
}

// 获取文章详情
export function getArticleDetail(articleId) {
  return request({
    url: `/admin/articles/${articleId}`,
    method: 'get'
  })
}

// 添加文章
export function addArticle(data) {
  return request({
    url: '/admin/articles',
    method: 'post',
    data
  })
}

// 更新文章
export function updateArticle(articleId, data) {
  return request({
    url: `/admin/articles/${articleId}`,
    method: 'put',
    data
  })
}

// 删除文章
export function deleteArticle(articleId) {
  return request({
    url: `/admin/articles/${articleId}`,
    method: 'delete'
  })
}

// 上传文章配图
export function uploadArticleImage(file) {
  const formData = new FormData()
  formData.append('file', file)
  
  return request({
    url: '/admin/upload/image',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
} 